package com.example.mountainwalker.controller;

import com.example.mountainwalker.entity.ScenicCommentInfo;
import com.example.mountainwalker.entity.ScenicFavoriteInfo;
import com.example.mountainwalker.service.ScenicFavoriteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sf")
@CrossOrigin
public class ScenicFavoriteController {

    @Autowired
    private ScenicFavoriteService scenicFavoriteService;

    @GetMapping("/list")
    public List<ScenicFavoriteInfo> getScenicFavoriteList() {
        return scenicFavoriteService.getScenicFavoriteInfo();
    }

    @GetMapping("/find")
    public ScenicFavoriteInfo getScenicFavoriteById(@RequestParam Integer id) {
        return scenicFavoriteService.getScenicFavoriteInfoById(id);
    }

    @PutMapping("/update")
    public ResponseEntity<Integer> updateScenicFavoriteInfo(@RequestBody ScenicFavoriteInfo scenicFavoriteInfo) {
        System.out.println("更新数据：" + scenicFavoriteInfo);
        return ResponseEntity.ok(scenicFavoriteService.updateScenicFavoriteInfo(scenicFavoriteInfo));
    }
}